package com.tech.cloudapp.controller;


import com.tech.cloudapp.biz.service.IBQuestionUserAllService;
import com.tech.cloudapp.db.entity.QuestionUserAll;
import com.tech.cloudapp.exception.BusinessException;
import com.tech.cloudapp.model.CommonResponseDO;
import com.tech.cloudapp.po.QuestionUserAllPO;
import com.tech.cloudapp.util.BeanCopyUtils;
import com.tech.cloudapp.util.JwtUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 用户答题汇总表 前端控制器
 * </p>
 *
 * @author mojianyou
 * @since 2025-03-23
 */
@RestController
@RequestMapping("/question-user-all")
public class QuestionUserAllController {

    @Autowired
    private IBQuestionUserAllService questionUserAllServiceImpl;

    @PostMapping("list")
    public CommonResponseDO list(@RequestBody QuestionUserAllPO questionUserAllPO, HttpServletRequest request) throws BusinessException {
        String userId = JwtUtil.extractUsername(request);
        QuestionUserAll questionUserAll = BeanCopyUtils.copyBean(questionUserAllPO, QuestionUserAll.class);
        questionUserAll.setUserId(userId);
        List<QuestionUserAll> questionUserAlls = questionUserAllServiceImpl.questionUserAllList(questionUserAll);
        return CommonResponseDO.success(questionUserAlls);
    }

}

